#include <iostream>
#include <cstdlib>

using namespace std;

int countchar(char *str,char a){
    int n = 0;
    int i = 0;
    
    while(*(str+i) != '\0'){
        if(*(str+i) == a){
        	n++;
		}
        i++;
    }
    return n;
}

int main() {
    char str[20], a;
    int n;
    
    gets(str);
    a = getchar();
    n = countchar(str,a);
    cout << n << endl;
}
